package com.cskaoyan.service.user.impl;

import com.cskaoyan.bean.po.MarketUser;
import com.cskaoyan.bean.vo.statistics.GoodsStatInnerRows;
import com.cskaoyan.bean.vo.statistics.OrderStatInnerRows;
import com.cskaoyan.bean.vo.statistics.UserStatInnerRows;
import com.cskaoyan.bean.vo.statistics.StatVo;
import com.cskaoyan.mapper.MarketOrderGoodsMapper;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import com.cskaoyan.service.user.UserStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * @author jzp
 * @since 2022/11/20 18:39
 */
@Service
public class UserStatServiceImpl implements UserStatService {
    @Autowired
    MarketUserMapper marketUserMapper;

    @Autowired
    MarketOrderMapper marketOrderMapper;

    @Autowired
    MarketOrderGoodsMapper marketOrderGoodsMapper;



    @Override
    public StatVo userStatistics() {
        StatVo<UserStatInnerRows> userStatVo = new StatVo<>();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        userStatVo.setColumns(columns);

        ArrayList<UserStatInnerRows> rows = marketUserMapper.userStatisticsGroupBy();

        userStatVo.setRows(rows);

        return userStatVo;
    }

    @Override
    public StatVo orderStatistics() {
        StatVo<OrderStatInnerRows> orderStatVo = new StatVo<>();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        orderStatVo.setColumns(columns);
        ArrayList<OrderStatInnerRows> rows = marketOrderMapper.orderStatisticsGroupBy();
        orderStatVo.setRows(rows);
        return orderStatVo;
    }

    @Override
    public StatVo goodsStatistics() {
        StatVo<GoodsStatInnerRows> goodsStatVo = new StatVo<>();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        goodsStatVo.setColumns(columns);
        ArrayList<GoodsStatInnerRows> rows = marketOrderGoodsMapper.goodsStatisticsGroupBy();
        goodsStatVo.setRows(rows);
        return goodsStatVo;
    }
}
